package day06.Ti.ZDYYC;

public class Student {
    private String name;
    private String xb;
    private int age;

    public Student() {
    }

    public Student(String name, String xb, int age) {
        this.name = name;
        this.xb = xb;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getXb() {
        return xb;
    }

    public void setXb(String xb) {
       if ("男".equals(xb)&&"女".equals(xb)){
           this.xb = xb;
       }
       throw new SexException("性别异常");
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age>=15&&age<=50){
            this.age = age;
        }
        throw new AgeException("年龄异常");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", xb='" + xb + '\'' +
                ", age=" + age +
                '}';
    }
}
